package com.byxm.wlgw.service;



import java.sql.ResultSet;

import com.byxm.wlgw.bean.YhxxBean;
import com.byxm.wlgw.common.DataBaseAccess;
import com.byxm.wlgw.query.YhxxQuery;

public class YhxxService { 
	YhxxQuery yhxxQuery=new YhxxQuery("tb_yhxx");
	/**
	 * 插入用户信息
	 * @param email
	 * @param yhmm
	 * @return
	 */
	public int insertYhxx(String email,String yhmm){
		DataBaseAccess dba = null;	
		int flagInsert=0;
		try {
			dba = new DataBaseAccess();
			flagInsert=dba.executeUpdate(yhxxQuery.getInsertYhxx(email, yhmm));
			dba.commit();
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			try {
				dba.releaseConnect();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return flagInsert;
	}
	/**
	 * 验证用户名密码
	 * @param email
	 * @param yhmm
	 * @return
	 */
	public YhxxBean getYhxxyz(String email,String yhmm){
		YhxxBean yhxx=new YhxxBean();
		yhxx.setEmail("");
		DataBaseAccess dba = null;	
		try {
			dba = new DataBaseAccess();
			String sql = yhxxQuery.getYhxxValidate(email, yhmm);
			ResultSet rs = dba.executeQuery(sql);
			if(rs.next()){
				yhxx.setEmail(rs.getString("email"));
				yhxx.setYhxxid(rs.getInt("yhxxid"));
			}
			rs.close();
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			try {
				dba.releaseConnect();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return yhxx;
	}
   
}
